home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / DOSTIPS4.ZIP / DOSSCTY.TXT < prev    next >
Text File  |  1986-06-28  |  16KB  |  314 lines

  1.                         Security Concerns
  2.        (PC Magazine Vol 5 No 1 January 14, 1986 PC Tutor)
  3.  
  4.      One of the consequences of the PC's open architecture is that
  5. password security is very difficult to implement.  Many corporate PC
  6. users live by a simple rule: If the file contains confidential
  7. information, it must be stored on a disk and kept in a locked desk.
  8. Typically, some paranoia accompanies this rule, such as requiring
  9. users to turn off the PCs after using a confidential file so nobody
  10. could DEBUG the data out of memory.
  11.      If your database is much too big and complex for disks, another
  12. solution is Iomega's Bernoulli Box.  The standard configuration comes
  13. with two 10-megabyte drives with removable cartridges.  Bernoulli Box
  14. access is faster than XT hard disk access, and the cartridges are more
  15. reliable, since they cannot crash.  Cartridges are removable, easy to
  16. back up, and they can be kept in a safe place when not in use.
  17.      If you have multiple users of a system, however, people may find
  18. it inconvenient to fetch a disk or Bernoulli Box cartridge whenever
  19. they need to use the database.  You could, therefore, replace the XT
  20. hard disk with another that is not quite so IBM compatible.  Such
  21. third-party hard disks generally require a driver program in a
  22. CONFIG.SYS file during boot time.  Thus, authorized users could be
  23. given a copy of the properly configured boot disk.  If the machine is
  24. turned off after each use, the hard disk could not be accessed without
  25. the right driver program.  (The Bernoulli Box without the boot option
  26. also needs a driver file, but if you left the cartridge itself in the
  27. machine, someone could walk away with it.)
  28.      Another possibility is to use an encryption and decryption
  29. program.  After using a confidential file, you'd run the encryption
  30. program with a password, which scrambles up the file.  When you wanted
  31. to use it again, you'd run the decryption program with the same
  32. password to unscramble it.  Low-cost encryption programs are readily
  33. available.  Such encryption schemes are very difficult to break without
  34. knowing the password, even if you should gain access to the decryption
  35. program.  Moreover, if someone maliciously tries to scramble up the
  36. encrypted program, it should be obvious when it's decrypted.  To
  37. protect against such contingencies, you should be keeping disk backups
  38. anyway.
  39.      Preventing someone from using your PC entirely is a little more
  40. difficult.  One solutin is a lock switch on the machine, something
  41. like the keyboard lock on the PC AT.  There are commercial locks that
  42. attach to the on/off switch on the PC and XT.
  43.      Putting a password program in an AUTOEXEC.BAT program does not
  44. work at all, since the user can break out of the batch file before the
  45. program is even executed.  You can put the password program in a dummy
  46. device driver.  Device drivers are loaded early in the boot process,
  47. and it would not be possible to break out of it.  However, someone can
  48. come along with a bootable disk and boot the machine from drive A:.
  49. DO NOT disable drive A: to prevent this.
  50.      You can, however, install a password program that cannot be
  51. circumvented by a drive A: boot.  This program has to be executed
  52. before the PC even attempts to boot.  Here's how it works.
  53.      When the PC is first turned on, it executes a "power-on self test"
  54. (POST) program coded in the PC's ROM BIOS.  This program initializes
  55. the system, checks memory and ultimately boots the operating system
  56. from a disk or hard disk.  Before the boot, however, the POST program
  57. checks memory locations between addresses C8000h and F4000h for the
  58. presence of additional read-only memory (ROM) programs.  Generally,
  59. these programs are used to perform some extra system initialization
  60. before the PC is booted.  In fact, the extra BIOS for the XT hard disk
  61. is at address C8000h.  You would have to program a small password
  62. routine somewhere in that memory space where it wouldn't conflict with
  63. anything else.  Moveover, the program must stay in memory when the PC
  64. is turned off.
  65.      Getting the password program encoded in ROM is a bit extreme.  An
  66. easier approach is to code it into random access memory on a CMOS RAM
  67. memory board with battery backup.  (Tecmar, for instances, sells a 32K
  68. CMOS RAM board through its Scientific Solutions subsidiary.)  CMOS RAM
  69. uses very little power -- almost none at all while inactive -- so a
  70. rechargeable battery backup should last for many months.
  71.      The board's memory address would be set up to begin at D0000h,
  72. d*000h, E0000h or E8000h.  The program must use a special format, which
  73. is explained in the ROM BIOS section of the PC or XT Tech Reference
  74. manuals under the heading "Adapter Cards with System-Accessible ROM
  75. Modules."  The code must start off with a 55h and AAh, to tell the
  76. BIOS that it is executable.  The third byte is the number of 512-byte
  77. blocks in the program -- probably 1 for a simple password routine.
  78. The program itself begins at the fourth byte, and it must return to
  79. the BIOS with a far return.  You should write the program in assembly
  80. language, and you may not use any DOS calls (Interrupts 20h and up)
  81. because DOS will not be loaded when the program runs.  You may,
  82. however, use all the BIOS resources for the keyboard and display.
  83.      The ROM BIOS does a check-sum of the bytes of the program and
  84. gives you a terse "ROM" message if they don't add up to zero ignoring
  85. overflow above 256.  So, you're going to have to add up all the bytes
  86. in your program, take the negative, and put that byte somewhere in the
  87. file.  The assembly language program below can get you started.  (This
  88. program has NOT been tested with a CMOS memory board, but it follows
  89. all the rules and should work.)  The use of the word "password" for a
  90. password is obviously a very poor choice and is used here only for
  91. illustration.  Note that there is no prompt for the password.  Not are
  92. the characters echoed to the display.  To someone who doesn't know
  93. that you've installed this, it will appear as if the machine is broken
  94. and will not boot.  Note also the nasty CLI and HLT code if a wrong
  95. letter is typed.  This will disable interrupts and halt the
  96. microprocessor, so even a "three-key" restart won't work.  Any
  97. tamperer would have to turn the machine off and back on to try again.
  98. You could omit the CLI to allow use of Ctrl-Alt-Del if a mismatch
  99. occurs.  You can get more elaborate and allow three retries and
  100. asterisk echoes and stuff like that.  For testing the guts of the
  101. program, you may want to set it up first as a regular .COM file and
  102. alter it for the ROM format after it's working.
  103.      Once you've MASMed, LINKed and EXE2BINed the ROM format program,
  104. you must add up all the bytes in it and find the two's complement (the
  105. byte that added to the rest will make zero, ignoring overflow above
  106. 256).  You could write a BASIC program to help out with this
  107. calculation.  Put the byte in after the CHECK label and reassemble.
  108.      When you're ready, load the final file into DEBUG and move it to
  109. the CMOS RAM board with the command line:  M 100 L 200 D000:0
  110. Reboot to test it out.  If it doesn't seem to work, you'll have to
  111. disable the memory board via a DIP switch and try to figure out what
  112. the problem is.  Debugging pre-boot ROM routines usually requires
  113. specialized tools and is not easy on a regular PC or XT.
  114.      If this project sounds like the ultimate headache, there is at
  115. least one commercially available board (from International Electronic
  116. Technology Corp.) that does virtually the same thing.  You create an
  117. 8-digit numeric password by setting DIP switches on the board.
  118.      Even though the board method seems pretty good, it is certainly
  119. not completely tamperproof.  Anyone encountering a PC reluctant to
  120. boot could simply open the PC, remove the offending board and restart
  121. the machine.  You may want to bolt the case down with fancy screws
  122. that require a special screwdriver.  And don't forget to protect
  123. yourself agains the ultimate security problem -- the one where you
  124. come to work in the morning and the PC is not there at all.
  125.  
  126. ;  PASSWORD.ASM for CMOS RAM
  127. ;
  128. CSEG     Segment
  129.    Assume     CS:CSEG
  130. Marker   db   55h, 0AAh, 1
  131.  
  132. Entry    Proc Far
  133.    Mov   BX,Offset Pword - 1
  134.    Mov   CX,8
  135.  
  136. Looper:  Sub  AH,AH
  137.    Int   16h
  138.    Inc   BX
  139.    Cmp   AL,CS:[BX]
  140.    Jnz   NoGood
  141.    Loop  Looper
  142.    Ret
  143.  
  144. NoGood:  Cli
  145.    Hlt
  146. Entry    EndP
  147.  
  148. Pword    db   'password'
  149. Check    db   ?
  150.    db  (512-($-Marker)) dup (0)
  151.  
  152. CSEG     Ends
  153.    End
  154.  
  155. -----------------------------------------------------------------
  156.                        Easy Data Security
  157.        (PC Magazine Vol 5 No 7 Apr 15, 1986 User-to-User)
  158.  
  159.      There's a simple but effective method for keeping data on a
  160. shared hard disk secure.  It won't fool a real expert, but it does
  161. screen most others out.
  162.      The trick is to use the ASCII character 255 either as part of a
  163. subdirectory name or a filename.  To create a subdirectory that few,
  164. if any, users will be able to access, type:
  165.  
  166. MD\SECRET
  167.  
  168. but add a CHR$(255) after the final T in SECRET by holding down the
  169. Alt key, typing 255 on the number pad, and then releasing the Alt key.
  170. After this has been done, all a snooping user will get by typing
  171. CD\SECRET is a frustrating "Invalid directory" message.  You can also
  172. use this trick with filenames, either by putting the CHR$(255) in the
  173. middle of the file or at the end.  In this case, users will get a
  174. "File not found" message.
  175.      Editor's Note:  This trick will fool most naive users who either
  176. won't see the CHR$(255) blank if it's at the end of a subdirectory or
  177. filename, or who will assume it's a conventional CHR$(32) space if it
  178. appears elsewhere in the name.  Not only will unauthorized users not
  179. be able to type the contents of such secured files, they also won't
  180. be able to copy or delete them.
  181.  
  182. -----------------------------------------------------------------
  183.                       Sneaky File Security
  184.       (PC Magazine Vol 5 No 11 June 10, 1986 User-to-User)
  185.  
  186.      While various programs on the market can encrypt DOS data files
  187. that contain sensitive information, there is one big limitation to all
  188. of them -- the user must manually call up the program, specify which
  189. file to encrypt, and then enter some sort of password.  Pity the poor
  190. soul who forgets the password!
  191.      It would make more sense to build the encryption directly into
  192. the program.  One simple method would be to add 128 to the ASCII value
  193. of each character in the file, but that requires extra code every time
  194. the program reads or writes.  Worse, it would be painfully slow when
  195. processing many records.
  196.      A better way is to write a Ctrl-Z at the beginning of the file --
  197. before any data is stored.  This prevents unauthorized users from
  198. snooping with the TYPE command or using the COPY command to send the
  199. file to a printer on the screen.  But it lets you copy the file to
  200. another disk.  For a nonprogrammer, the only way to get the data would
  201. be with a sector-reading utility like Norton's Utilities.
  202.      The HIDDEN.BAS program below creates and reads a simple name-and-
  203. address file, while demonstrating the technique described.  The only
  204. compromise is the space lost to the first record.  Note that this
  205. method will also work when writing a sequential file; however, it
  206. must be read as a random file using the FIELD and GET statements.
  207.  
  208. 100 'HIDDEN.BAS -- Reads/writes "hidden" files
  209. 110 'First, create "hidden" file
  210. 120 OPEN "NAMES" AS #1 LEN=80
  211. 130 FIELD #1,22 AS NAM$,22 AS STREET$,22 AS CITY$,14 AS PHONE$
  212. 140 LSET NAM$="Access Denied"+CHR$(26):PUT #1
  213. 150 FOR X=1 TO 9
  214. 160 LSET NAM$    = "Smith, John"
  215. 170 LSET STREET$ = "129 East 14th St. #"+MKI$(X+48)
  216. 180 LSET CITY$   = "New York, N.Y. 10028"
  217. 190 LSET PHONE$  = "(212) 555-1212"
  218. 200 PRINT "Writing record #";RIGHT$(STR$(X),1)
  219. 210 PUT #1:NEXT:CLOSE
  220. 220 'Show you can still read from "hidden" file
  221. 230 INPUT "Which record do you want to read (1-9): ",F$
  222. 240 IF VAL(F$)<1 or VAL(F$)>9 THEN BEEP:GOTO 230
  223. 250 OPEN "NAMES" AS #1 LEN=80
  224. 260 FIELD #1,22 AS NAM$,22 AS STREET$,22 AS CITY$,14 AS PHONE$
  225. 270 GET #1,VAL(F$)+1
  226. 280 PRINT NAM$:PRINT STREET$:PRINT CITY$:PRINT PHONE$
  227. 290 CLOSE
  228.  
  229. Editor's Note:  Software manufacturers have been using a variation of
  230. this trick for years, putting a copyright notice or a screen full of
  231. text at the beginning of a .COM or .EXE file, followed immediately by
  232. a Ctrl-Z end-of-file marker.  If users try to type the file, all they
  233. get is the message.
  234.      The trick in HIDDEN.BAS works only with naive users.  The first
  235. thing a typical user would do on seeing an "Access Denied" message is
  236. look at the contents using DEBUG's (D)ump command.  Or he would write
  237. a small program to read the file byte by byte:
  238.  
  239. 100 'Random file reader
  240. 110 OPEN "NAMES" as #1 LEN=1
  241. 120 FIELD 1,1 AS A$
  242. 130 FOR A=1 to LOF(1)
  243. 140 GET 1,A:PRINT A$;
  244. 150 NEXT
  245.  
  246. Obviously, you should substitute the name of the file in question for
  247. NAMES in line 110.  And you can speed things up considerably by
  248. increasing the LEN record length beyond one character.
  249.      Incidentally, while adding 128 (or any other value from 1 to 128)
  250. to each character in a file is a very unsophisticated security device,
  251. it will also keep casual snoopers away and is simple to do.  To try
  252. this with the NAMES file created by the HIDDEN.BAS program, simply run
  253. the following program:
  254.  
  255. 100 'Trivial encryptor
  256. 110 OPEN "NAMES" AS #1 LEN=1
  257. 120 OPEN "NEWNAMES" AS #2 LEN=1
  258. 130 FIELD 1,1 AS A$
  259. 140 FIELD 2,1 AS B$
  260. 150 FOR A=1 to LOF(1)
  261. 160 GET 1,A
  262. 170 LSET B$=CHR$(ASC(A$) XOR 128)
  263. 180 PUT #2,A
  264. 190 NEXT:CLOSE
  265.  
  266. (Be sure the NAMES file you created in the previous example is on the
  267. same disk as this trivial encryptor, or it won't have anything to
  268. encrypt.)
  269.      If a user types the contents of the NEWNAMES file, all he'll see
  270. is meaningless "high-bit" characters.  To unscramble the NEWNAMES file,
  271. just run this program:
  272.  
  273. 100 'Trivial decryptor
  274. 110 OPEN "NEWNAMES" AS #1 LEN=1
  275. 120 FIELD 1,1 as A$
  276. 130 FOR A=1 to LOF(1)
  277. 140 GET 1,A
  278. 150 PRINT CHR$(ASC(A$) XOR 128);
  279. 160 NEXT:CLOSE
  280.  
  281.      Instead of using the 128 in the two previous programs, you can
  282. substitute any number from 1 to 127, but make sure you do it in both
  283. the encryptor and decryptor programs.  It's easy to beat such a trivial
  284. transposition encryption scheme.  To do so, just look at the contents
  285. with the DOS TYPE or DEBUG Dump commands.  Random access files pad out
  286. unused fields with space characters (CHR$(32)).  The encryptor file
  287. above will uniformly change them to something else.  In this example,
  288. it will be an a with a dot over it (CHR$(160), since 32 + 128 = 160).
  289. It's easy to see these characters padding out fields of different
  290. sizes.  Once you find the "encryptor" space character, subtract 32
  291. from it and XOR all the characters with the value of the difference.
  292.  
  293. -----------------------------------------------------------------
  294.                          Security Leaks
  295.       (PC Magazine Vol 5 No 11 June 10, 1986 User-to-User)
  296.  
  297.      A person used the encryption feature of SuperKey to "keep safe"
  298. sensitive correspondence on a hard disk.  In checking these safety
  299. measures, the results were enlightening.
  300.      In this instance, a well-known word processor was used that
  301. produces .BAK files with each new or changed document, and the .BAK
  302. files were erased.  After a couple of minutes with Norton Utilities,
  303. it was possible to unerase these unprotected backup files.  Now the
  304. person uses Norton's FileWipe program to complete erase backup files
  305. or encrypts them before erasing.
  306.      However, in addition to the visible .BAK files, this particular
  307. word processor produced several working files (with .$$$ and .@@@
  308. extensions).  Therefore, the person has to use Norton Utilities to
  309. unerase the working files and then FileWipe or encrypt them.
  310.      The moral is that just encrypting the working file is not enough.
  311. Make sure all copies of the file are either encrypted or erased with a
  312. program that will prevent them from being recovered.
  313.  
  314.